package org.streets.eis.component.grid;


import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.model.IModel;

import com.inmethod.grid.column.AbstractColumn;
import org.streets.eis.component.datetime.DateField;
import org.streets.eis.component.datetime.DateTimeField;
import org.streets.eis.component.datetime.TimeField;

public class DateTimeColumn extends EditableColumn {
	private static final long serialVersionUID = 1L;

	private ColumnType.DateTime dateTimeType = ColumnType.DateTime.DATE;
	
	@SuppressWarnings("unchecked")	
	public DateTimeColumn(String columnId, IModel headerModel, String propertyExpression, String sortProperty) {
		this(columnId, headerModel, propertyExpression, sortProperty,ColumnType.DateTime.DATE);
	}

	@SuppressWarnings("unchecked")	
	public DateTimeColumn(String columnId, IModel headerModel, String propertyExpression, String sortProperty,ColumnType.DateTime dateTimeType) {
		super(columnId, headerModel, propertyExpression, sortProperty);
		this.dateTimeType = dateTimeType;
	}
	
	@SuppressWarnings("unchecked")	
	public DateTimeColumn(String columnId, IModel headerModel, String propertyExpression) {
		this(columnId, headerModel, propertyExpression,ColumnType.DateTime.DATE);
	}
	
	@SuppressWarnings("unchecked")	
	public DateTimeColumn(String columnId, IModel headerModel, String propertyExpression,ColumnType.DateTime dateTimeType) {
		super(columnId, headerModel, propertyExpression);
		this.dateTimeType = dateTimeType;
	}

	@SuppressWarnings("unchecked")	
	public DateTimeColumn(IModel headerModel, String propertyExpression, String sortProperty) {
		this(headerModel, propertyExpression, sortProperty,ColumnType.DateTime.DATE);
	}
	
	@SuppressWarnings("unchecked")	
	public DateTimeColumn(IModel headerModel, String propertyExpression, String sortProperty,ColumnType.DateTime dateTimeType) {
		super(headerModel, propertyExpression, sortProperty);
		this.dateTimeType = dateTimeType;
	}
	
	@SuppressWarnings("unchecked")	
	public DateTimeColumn(IModel headerModel, String propertyExpression) {
		this(headerModel, propertyExpression,ColumnType.DateTime.DATE);
	}
	
	@SuppressWarnings("unchecked")	
	public DateTimeColumn(IModel headerModel, String propertyExpression,ColumnType.DateTime dateTimeType) {
		super(headerModel, propertyExpression);
		this.dateTimeType = dateTimeType;
	}	
	
	@SuppressWarnings("unchecked")
	@Override
	protected FormComponent newEditableComponent(String id, final IModel model, IModel rowModel, AbstractColumn column){
		switch (dateTimeType){
		case TIME : return new TimeField(id,model);
		case DATETIME : return new DateTimeField(id,model);
		default : return new DateField(id, model);
		}
	}
	
}
